<div id="site_search">
    <input type="text" id="search_box" class="form-control" placeholder="Search.....">
</div>

<ul class="content-ul" id="search_results" recent></ul>

<style>
.form-control {
    display: block;
    width: 85%;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
</style>

<!--
<script src="/js/simple-jekyll-search.min.js" charset="utf-8"></script>
<script src="https://unpkg.com/simple-jekyll-search/dest/simple-jekyll-search.min.js"></script>
-->
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-99-y/simple-jekyll-search/1.9.2/simple-jekyll-search.min.js" type="application/javascript"></script>
<script type="text/javascript">
// Simple-Jekyll-Search是个开源项目，托管在https://github.com/christian-fei/Simple-Jekyll-Search
SimpleJekyllSearch({
    searchInput          : document.getElementById('search_box'),                  // 监听输入框（只要输入框的值发生变化，搜索结果的容器也发生变化）
    resultsContainer     : document.getElementById('search_results'),              // 存放搜索结果的容器（一般是ul）
    searchResultTemplate : '<li><a href="{url}" target="_blank">{title}</a></li>', // 设置搜索结果的每一项的渲染方式
    json                 : '/js/simple-jekyll-search-data.json',                          // 该文件的作用是生成搜索的数据索引
    noResultsText        : 'No results found',                                     // 无搜索数据提示语
    limit                : 8,                                                      // 返回最多文章数
    fuzzy                : false                                                   // 是否模糊匹配
});

// function adjust_search_box_width(){
//     if($(".post-directory").length){
//         if($(".post-directory").is(":visible")){
//             $("#site_search").width(300);
//         }
//     }
//     var searchbar_width = $("#site_search").width();
//     $("#search_box").width(searchbar_width - 15);
// }
//
// adjust_search_box_width();
//
// $(window).on("resize", function(){
//     adjust_search_box_width();
// });
</script>